/* ------------------------------------------------------------------------- *
 * Copyright (C) 2007 Arne Claassen
 *
 * Arne Claassen <lfslib [at] claassen [dot] net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * ------------------------------------------------------------------------- */
using System;
using System.Collections.Generic;
using System.Text;

namespace FullMotion.LiveForSpeed.InSim.Packets
{
  // TEXT MESSAGES AND KEY PRESSES
  // ==============================

  // You can send 64-byte text messages to LFS as if the user had typed them in.
  // Messages that appear on LFS screen (up to 128 bytes) are reported to the
  // external program.  You can also send simulated keypresses to LFS.

  // MESSAGES OUT (FROM LFS)
  // ------------

  /// <summary>
  /// MSg Out - system messages and user messages 
  /// </summary>
  struct IS_MSO : ILfsInSimPacket
  {
    public byte Size;		// 136
    public Enums.ISP Type;		// ISP_MSO
    public byte ReqI;		// 0
    public byte Zero;

    public byte UCID;		// connection's unique id (0 = host)
    public byte PLID;		// player's unique id (if zero, use UCID)
    public Enums.UserType UserType;	// set if typed by a user (see User Values below) 
    public byte TextStart;	// first character of the actual text (after player name)

    public byte[] Msg; //[128];

    public IS_MSO(byte[] bytes)
    {
      int position = 0;
      Size = bytes[position++];
      Type = (Enums.ISP)bytes[position++];
      ReqI = bytes[position++];
      position++;
      Zero = 0;
      UCID = bytes[position++];
      PLID = bytes[position++];
      UserType = (Enums.UserType)bytes[position++];
      TextStart = bytes[position++];
      Msg = new byte[128];
      Array.Copy(bytes, position, Msg, 0, 128);
    }

    #region ILfsInSimPacket Members

    public Enums.ISP PacketType
    {
      get { return Type; }
    }

    #endregion
  }
}
